import 'package:flutter_admin/utils/utils.dart';

class Test {
  String? moveLineIds;
  String? id;
  String? name;
  String? locationId;
  String? locationName;
  String? locationTypeId;
  String? locationDestId;
  String? locationDestName;
  String? pickingTypeId;
  String? pickingTypeName;
  String? createUid;
  String? createDate;
  String? createDateStart;
  String? createDateEnd;
  String? writeUid;
  String? writeDate;
  String? productorderno;
  String? batchno;
  String? processId;
  String? processName;
  String? stationId;
  String? stationName;
  String? instockuserId;
  String? instockuserName;

  Test({
    this.moveLineIds,
    this.id,
    this.name,
    this.locationId,
    this.locationName,
    this.locationTypeId,
    this.locationDestId,
    this.locationDestName,
    this.pickingTypeId,
    this.pickingTypeName,
    this.createUid,
    this.createDate,
    this.createDateStart,
    this.createDateEnd,
    this.writeUid,
    this.writeDate,
    this.productorderno,
    this.batchno,
    this.processId,
    this.processName,
    this.stationId,
    this.stationName,
    this.instockuserId,
    this.instockuserName,
  });

  Test copyWith({
    String? id,
    String? moveLineIds,
    String? name,
    String? locationId,
    String? locationDestId,
    String? pickingTypeId,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
    String? productorderno,
    String? batchno,
    String? processId,
    String? stationId,
    String? instockuserId,
  }) {
    return new Test(
      moveLineIds: moveLineIds ?? this.moveLineIds,
      id: id ?? this.id,
      name: name ?? this.name,
      locationId: locationId ?? this.locationId,
      locationDestId: locationDestId ?? this.locationDestId,
      pickingTypeId: pickingTypeId ?? this.pickingTypeId,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
      productorderno: productorderno ?? this.productorderno,
      batchno: batchno ?? this.batchno,
      processId: processId ?? this.processId,
      stationId: stationId ?? this.stationId,
      instockuserId: instockuserId ?? this.instockuserId,
    );
  }

  @override
  String toString() {
    return '''Test{
      moveLineIds: moveLineIds,
      id: id,
      name: name,
      locationId: locationId,
      locationDestId: locationDestId,
      pickingTypeId: pickingTypeId,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
      productorderno: productorderno,
      batchno: batchno,
      processId: processId,
      stationId: stationId,
      instockuserId: instockuserId,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is Test &&
          moveLineIds == other.moveLineIds &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          name == other.name &&
          locationId == other.locationId &&
          locationDestId == other.locationDestId &&
          pickingTypeId == other.pickingTypeId &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate &&
          productorderno == other.productorderno &&
          batchno == other.batchno &&
          processId == other.processId &&
          stationId == other.stationId &&
          instockuserId == other.instockuserId);

  factory Test.fromMap(Map<String, dynamic> map) {
    return new Test(
      moveLineIds: map['move_line_ids'] != false
          ? map['move_line_ids'].toString() as String?
          : "",
      id: map['id'] != false ? map['id'].toString() as String? : "",
      name: map['name'] != false ? map['name'].toString() as String? : "",
      locationId: map['location_id'] != false
          ? map['location_id'][0].toString() as String?
          : "",
      locationName: map['location_id'] != false
          ? map['location_id'][1].toString() as String?
          : "",
      // locationTypeId: "",
      locationDestId: map['location_dest_id'] != false
          ? map['location_dest_id'].toString() as String?
          : "",
      locationDestName: map['location_dest_id'] != false
          ? map['location_dest_id'][1].toString() as String?
          : "",
      pickingTypeId: map['picking_type_id'] != false
          ? map['picking_type_id'].toString() as String?
          : "",
      pickingTypeName: map['picking_type_id'] != false
          ? map['picking_type_id'][1].toString() as String?
          : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
      productorderno: map['productorderno'] != false
          ? map['productorderno'].toString() as String?
          : "",
      batchno:
          map['batchno'] != false ? map['batchno'].toString() as String? : "",
      processId: map['process_id'] != false
          ? map['process_id'].toString() as String?
          : "",
      processName: map['process_id'] != false
          ? map['process_id'][1].toString() as String?
          : "",
      stationId: map['station_id'] != false
          ? map['station_id'].toString() as String?
          : "",
      stationName: map['station_id'] != false
          ? map['station_id'][1].toString() as String?
          : "",
      instockuserId: map['instockuser_id'] != false
          ? map['instockuser_id'].toString() as String?
          : "",
      instockuserName: map['instockuser_id'] != false
          ? map['instockuser_id'][1].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'moveLineIds': this.moveLineIds,
      'id': this.id,
      'name': this.name,
      'locationId': this.locationId,
      'locationDestId': this.locationDestId,
      'pickingTypeId': this.pickingTypeId,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
      'productorderno': this.productorderno,
      'batchno': this.batchno,
      'processId': this.processId,
      'stationId': this.stationId,
      'instockuserId': this.instockuserId,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.name != null && this.name != '')
        ['name', 'like', '%${this.name}%'],
      if (this.productorderno != null && this.productorderno != '')
        ['productorderno', 'like', '%${this.productorderno}%'],
      if (this.locationTypeId != null && this.locationTypeId != '')
        ['location_id', '=', this.locationTypeId],
      if (this.createDate != null && this.createDate != '')
        ['create_date', '=', this.createDate],
      if (this.createDateStart != null && this.createDateStart != '')
        [
          'create_date',
          '>=',
          Utils.timeUTC(this.createDateStart, isToBeijing: false)
        ],
      if (this.createDateEnd != null && this.createDateEnd != '')
        [
          'create_date',
          '<=',
          Utils.timeUTC(this.createDateEnd, isToBeijing: false)
        ],
    ] as List;
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'moveLineIds': this.moveLineIds,
      'id': this.id,
      'name': this.name,
      'location_id': this.locationId,
      'location_dest_id': this.locationDestId,
      'picking_type_id': this.pickingTypeId,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
      'productorderno': this.productorderno,
      'batchno': this.batchno,
      'process_id': this.processId,
      'station_id': this.stationId,
      'instockuser_id': this.instockuserId,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
